package com.xmrj.demo.controller;
/*
    徐翔宇
    交替打印99乘法表

 */

public class JSQController {
    static int x=1;
    static int y=1;
    public static class A extends Thread{
        @Override
        public void run() {
            int b=x*y;
            if(x <=9){
                String a= String.valueOf(b);
                System.out.println("线程1:"+x+"*"+y+"="+a);
                y=y+1;
                if (y==10){
                    y=1;
                    x=x+1;
                }
            }else {
                System.out.println("输出结束");
            }

        }
    }
    public static class B extends Thread{
        @Override
        public void run() {
            int b=x*y;
            if(x <=9){
                String a= String.valueOf(b);
                System.out.println("线程2:"+x+"*"+y+"="+a);
                y=y+1;
                if (y==10){
                    y=1;
                    x=x+1;
                }
            }else {
                System.out.println("输出结束");
            }

        }
    }
    public static void main(String[] args) {

        while (x<10)
        {
            Thread A=new A();
            Thread B=new B();

            try {
                A.start();
                Thread.sleep(1);
                B.start();
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        System.out.println(x+y);

        System.out.println("主线程运行结束!");
    }


}
